//
//  NRWBuyCarFilterManager.m
//  NRWMall
//
//  Created by 邢毅 on 2018/6/7.
//  Copyright © 2018年 com.anpxd. All rights reserved.
//

#import "NRWBuyCarFilterManager.h"

#import "NRWBuyCarConditionModel.h"
#import "NRWBuyCarFilterHeaderModel.h"

@implementation NRWBuyCarFilterManager

+ (NSArray<NRWBuyCarSortModel *> *)getSortContentModelArray {
    
    NRWBuyCarSortModel *model0 = [[NRWBuyCarSortModel alloc] init];
    model0.sortName = @"默认排序";
    model0.sortId = @"0";
    model0.isSelect = YES;
    
    NRWBuyCarSortModel *model1 = [[NRWBuyCarSortModel alloc] init];
    model1.sortName = @"最新发布";
    model1.sortId = @"1";
    model1.isSelect = NO;
    
    NRWBuyCarSortModel *model2 = [[NRWBuyCarSortModel alloc] init];
    model2.sortName = @"价格最低";
    model2.sortId = @"2";
    model2.isSelect = NO;
    
    NRWBuyCarSortModel *model3 = [[NRWBuyCarSortModel alloc] init];
    model3.sortName = @"价格最高";
    model3.sortId = @"3";
    model3.isSelect = NO;
    
    NRWBuyCarSortModel *model4 = [[NRWBuyCarSortModel alloc] init];
    model4.sortName = @"车龄最短";
    model4.sortId = @"4";
    model4.isSelect = NO;
    
    NRWBuyCarSortModel *model5 = [[NRWBuyCarSortModel alloc] init];
    model5.sortName = @"里程最少";
    model5.sortId = @"5";
    model5.isSelect = NO;
    
    return @[model0, model1, model2, model3, model4, model5];
}

+ (NSArray<NRWBuyCarPriceModel *> *)getPriceModelArray {
    
    NRWBuyCarPriceModel *model1 = [[NRWBuyCarPriceModel alloc] init];
    model1.priceFrom = nil;
    model1.priceTo = nil;
    model1.isSelect = YES;
    model1.priceTitle = @"不限";
    
    NRWBuyCarPriceModel *model2 = [[NRWBuyCarPriceModel alloc] init];
    model2.priceFrom = @"0";
    model2.priceTo = @"3";
    model2.priceTitle = @"0-3万";
    
    NRWBuyCarPriceModel *model3 = [[NRWBuyCarPriceModel alloc] init];
    model3.priceFrom = @"3";
    model3.priceTo = @"5";
    model3.priceTitle = @"3-5万";
    
    NRWBuyCarPriceModel *model4 = [[NRWBuyCarPriceModel alloc] init];
    model4.priceFrom = @"5";
    model4.priceTo = @"10";
    model4.priceTitle = @"5-10万";
    
    NRWBuyCarPriceModel *model5 = [[NRWBuyCarPriceModel alloc] init];
    model5.priceFrom = @"10";
    model5.priceTo = @"15";
    model5.priceTitle = @"10-15万";
    
    NRWBuyCarPriceModel *model6 = [[NRWBuyCarPriceModel alloc] init];
    model6.priceFrom = @"15";
    model6.priceTo = @"20";
    model6.priceTitle = @"15-20万";
    
    NRWBuyCarPriceModel *model7 = [[NRWBuyCarPriceModel alloc] init];
    model7.priceFrom = @"20";
    model7.priceTo = @"30";
    model7.priceTitle = @"20-30万";
    
    NRWBuyCarPriceModel *model8 = [[NRWBuyCarPriceModel alloc] init];
    model8.priceFrom = @"30";
    model8.priceTo = @"50";
    model8.priceTitle = @"30-50万";
    
    NRWBuyCarPriceModel *model9 = [[NRWBuyCarPriceModel alloc] init];
    model9.priceFrom = @"50";
    model9.priceTo = nil;
    model9.priceTitle = @"50万以上";
    
    return @[model1, model2, model3, model4, model5, model6, model7, model8, model9];
}

+ (NSArray<NRWBuyCarFilterHeaderModel *> *)getBuyCarFilterTitleArray {
    
    NRWBuyCarFilterHeaderModel *model1 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model1.title = @"里程/单位 (万公里)";
    model1.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model2 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model2.title = @"车龄/单位 (年)";
    model2.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model3 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model3.title = @"颜色";
    model3.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model4 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model4.title = @"车身类型";
    model4.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model5 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model5.title = @"环保类型";
    model5.detail = @"不限";
    
    return @[model1, model2, model3, model4, model5];
}

+ (NSArray<NRWBuyCarFilterHeaderModel *> *)getSubscribeTitleArray {
    
    NRWBuyCarFilterHeaderModel *model0 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model0.title = @"价格区间";
    model0.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model1 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model1.title = @"车龄/单位 (年)";
    model1.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model2 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model2.title = @"里程/单位 (万公里)";
    model2.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model3 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model3.title = @"变速箱";
    model3.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model4 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model4.title = @"颜色";
    model4.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model5 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model5.title = @"车身类型";
    model5.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model6 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model6.title = @"环保类型";
    model6.detail = @"不限";
    
    NRWBuyCarFilterHeaderModel *model7 = [[NRWBuyCarFilterHeaderModel alloc] init];
    model7.title = @"亮点配置";
    model7.detail = @"不限";
    
    return @[model0, model1, model2, model3, model4, model5, model6, model7];
}

+ (NSArray<NSString *> *)getBuyCarMileageTitleArray {
    
    return @[@"0", @"1", @"3", @"6", @"10", @"不限"];
}

+ (NSArray<NSString *> *)getBuyCarAgeTitleArray {
    
    return @[@"0", @"1", @"2", @"3", @"4", @"5", @"10", @"不限"];
}

+ (NSArray<NSString *> *)getPriceSliderTitleArray {
    
    return @[@"0", @"5", @"15", @"20", @"30", @"50", @"100", @"不限"];
}

+ (void)setValueForModel:(NRWBuyCarFilterModel *)model headerModel:(NRWBuyCarFilterHeaderModel *)headerModel withTitleModel:(NSArray<NSString *> *)titleArray firstIndex:(NSInteger)first lastIndex:(NSInteger)last type:(NRWBuyCarFilterType)type {
    
    if (type == NRWBuyCarFilterTypeMileage) {
        
        if (first == 0 && last == titleArray.count - 1) {
            
            model.mileageTitle = headerModel.detail = @"不限";
            model.mileageFrom = model.mileageTo = nil;
        } else if (first != 0 && last == titleArray.count - 1) {
            
            model.mileageTitle = headerModel.detail = [NSString stringWithFormat:@"%@万公里以上", titleArray[first]];
            model.mileageFrom = titleArray[first];
            model.mileageTo = nil;
        } else {
            model.mileageTitle = headerModel.detail = [NSString stringWithFormat:@"%@~%@万公里", titleArray[first], titleArray[last]];
            model.mileageFrom = titleArray[first];
            model.mileageTo = titleArray[last];
        }
        
        model.mileageFirstIndex = first;
        model.mileageLastIndex = last;
    } else {
        
        if (first == 0 && last == titleArray.count - 1) {
            
            model.carAgeTitle = headerModel.detail = @"不限";
            model.carAgeFrom = model.carAgeTo = nil;
        } else if (first != 0 && last == titleArray.count - 1) {
            
            model.carAgeTitle = headerModel.detail = [NSString stringWithFormat:@"%@年以上", titleArray[first]];
            model.carAgeFrom = titleArray[first];
            model.carAgeTo = nil;
        } else {
            model.carAgeTitle = headerModel.detail = [NSString stringWithFormat:@"%@~%@年", titleArray[first], titleArray[last]];
            model.carAgeFrom = titleArray[first];
            model.carAgeTo = titleArray[last];
        }
        
        model.carAgeFirstIndex = first;
        model.carAgeLastIndex = last;
    }
}

@end
